{namespace form=TYPO3\CMS\Form\ViewHelpers}
<f:if condition="{model.showElement}">
	<f:format.raw>{model.layout.elementOuterWrap.0}</f:format.raw>

	<f:for each="<form:aggregateSelectOptions model='{model}' />" as="option">
		<f:if condition="{option.options}">
			<f:then>
				<f:for each="{option.options}" as="optgroupOption">
					<f:if condition="{optgroupOption.selected} == 'selected'">
						<f:format.raw>{model.layout.optionOuterWrap.0}</f:format.raw>{optgroupOption.label}<f:format.raw>{model.layout.optionOuterWrap.1}</f:format.raw>
					</f:if>
				</f:for>
			</f:then>
			<f:else>
				<f:if condition="{option.selected} == 'selected'">
					<f:format.raw>{model.layout.optionOuterWrap.0}</f:format.raw>{option.label}<f:format.raw>{model.layout.optionOuterWrap.1}</f:format.raw>
				</f:if>
			</f:else>
		</f:if>
	</f:for>

	<f:format.raw>{model.layout.elementOuterWrap.1}</f:format.raw>
</f:if>
